from datetime import datetime
from typing import List, Optional
from pydantic import BaseModel


class DashboardStatsResponse(BaseModel):
    """控制台统计数据响应模型"""
    total_users: int
    active_users: int
    total_tasks: int
    running_tasks: int
    completed_tasks: int
    failed_tasks: int
    total_crawlers: int
    running_crawlers: int
    ai_models: int
    active_models: int
    data_volume: str
    daily_requests: int
    success_rate: float


class SystemStatsResponse(BaseModel):
    """系统状态响应模型"""
    cpu_usage: float
    memory_usage: float
    memory_total: float
    memory_used: float
    disk_usage: float
    disk_total: float
    disk_used: float
    network_sent: float
    network_recv: float
    processes: int
    uptime_days: int
    uptime_hours: int
    uptime_minutes: int


class ActivityItem(BaseModel):
    """活动项目模型"""
    id: int
    type: str  # task, system, user, alert, crawler
    title: str
    description: str
    timestamp: datetime
    status: str  # success, error, warning, info, running
    user_id: int


class RecentActivityResponse(BaseModel):
    """最近活动响应模型"""
    total: int
    activities: List[ActivityItem]


class QuickStatsItem(BaseModel):
    """快速统计项目模型"""
    tasks_completed: int
    data_processed: str
    api_calls: int
    success_rate: float


class QuickStatsResponse(BaseModel):
    """快速统计响应模型"""
    today: QuickStatsItem
    yesterday: QuickStatsItem
    this_week: QuickStatsItem
    this_month: QuickStatsItem